// 用户状态
import { requLogin } from '@/api/login'

export default {
  namespaced: true,
  state: () => {
    return {
      profile: {
        id: '',
        nickname: '我是东东啊',
        token: ''
      }
    }
  },
  mutations: {
    setname (state, name) {
      state.profile.nickname = name
    },
    // 设置用户信息
    setprofile (state, nweprofile) {
      state.profile = nweprofile
    },
    // 退出登录
    clearProfile (state) {
      state.profile = {
        id: '',
        nickname: '',
        avatar: '',
        token: '',
        mobile: ''
      }
    }
  },
  actions: {
    async login (store, form) {
      const { result } = await requLogin(form)
      console.log('登录', result)
      store.commit('setprofile', result)
    }
  }
}
